package com.qhg.saas_server.controller;


import com.qhg.saas_server.empty.Result;
import com.qhg.saas_server.pojo.Authority;
import com.qhg.saas_server.service.AuthorityService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

;

/**
 *@作者:lsk
 *Controller接口
 *@Date:2023/07/13
*/
@CrossOrigin
@RestController
@RequestMapping("/AuthorityURL")
public class AuthorityController {


	@Autowired
	private AuthorityService authorityservice;


	/**
	 * 删除角色管理权限
	 */
	@PostMapping("/deleteAutority")
	public Result deleteAutority(@RequestBody Map map){
		return Result.success(authorityservice.deleteAuthority(map));
	}


	/**
	 * 连表查询角色的权限
	 */
	@GetMapping("/selectRoleAuthority/{id}")
	public Result selectRoleAuthority(@PathVariable(value = "id") String roleId){
		return Result.success(authorityservice.selectRoleAuthority(roleId));
	}

	/**
	 insert:(插入)
	*/
	@PostMapping("/insert")
	public Result insert(@RequestBody Authority demo){
		Result.success(authorityservice.insert(demo));
		return Result.success(demo);
	}



	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	@PostMapping("/insertOrUpdate")
	public Result insertOrUpdate(@RequestBody Authority demo){
		return Result.success(authorityservice.insertOrUpdate(demo));
	}



	/**
	 insertBath:(批量插入)
	*/
	@PostMapping("/insertBatch")
	public Result insertBatch(@RequestBody List<Authority> list){
		return Result.success(authorityservice.insertBatch(list));
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	@PostMapping("/insertOrUpdateBatch")
	public Result insertOrUpdateBatch(@RequestBody List<Authority> list){
		return Result.success(authorityservice.insertOrUpdateBatch(list));
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	@PostMapping("/selectList")
	public Result selectList(@RequestBody Map<String,Object> param){

		return Result.success(authorityservice.selectList(param));
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	@PostMapping("/selectCount")
	public Result selectCount(@RequestBody Map<String,Object> param){
		return Result.success(authorityservice.selectCount(param));
	}



}